#include <iostream>
#include <stdio.h>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <numeric>
#include <string.h>
#include <cstdlib>
#include <ctime>
using namespace std;

class oralMath
{
    int maxNum;
    int queNum;
    char queMethod;
    int answer[100];
    public:
    oralMath(int x,int y,char z);
    int getRandom();
    int getAnswer(int x, int y);
    void save_Question();
    void save_Answer();
};
oralMath::oralMath(int x,int y,char z):maxNum(x),queNum(y),queMethod(z)
{}
int oralMath::getRandom()
{
    return rand() % (maxNum-0+1);
}
int oralMath::getAnswer(int x, int y)
{
    if(queMethod=='+')
    {
        return x+y;
    }
    if(queMethod=='-')
    {
        return x-y;
    }
    if(queMethod=='*')
    {
        return x*y;
    }
    if(queMethod=='/')
    {
        return x/y;
    }
    else{
        return 0;
    }
}
void oralMath::save_Question()
{
    int temp1,temp2;
    ofstream saveQuestion;
    saveQuestion.open("text.txt");
    for(int i=0;i<queNum;i++)
    {
        temp1=getRandom();
        temp2=getRandom();
        answer[i]=getAnswer(temp1,temp2);
        saveQuestion<<temp1<<queMethod<<temp2<<"="<<endl;
    }
    saveQuestion.close();
}
void oralMath::save_Answer()
{
    ofstream saveAnswer;
    saveAnswer.open("answer.txt");
    for(int i=0;i<queNum;i++)
    {
        
        saveAnswer<<i+1<<"."<<answer[i]<<endl;
    }
    saveAnswer.close();
}

int main()
{   
    int max,que;
    char med;
    ifstream read_index;
    read_index.open("oralmath.txt");
    read_index>>max>>que>>med;
    read_index.close();
    oralMath t(max,que,med);
    t.save_Question(); 
    t.save_Answer();
    return 0;
}